mongo = require 'mongodb'
server = new mongo.Server("127.0.0.1", 27017, {})
client = new mongo.Db("test", server)
test = (err, collection) ->
  collection.insert {a: 2},   (err, docs) ->
    collection.count   (err, count) ->
      test.assertEquals 1, count
      
    collection.find().toArray   (err, results) ->
      test.assertEquals 1, results.length
      test.assertTrue results.a is 2
      client.close()

client.open (err, p_client) ->
  client.collection "test_insert", test